package com.lagou.task03;

import java.io.*;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 *
 * 使用线程池将一个目录中的所有内容拷贝到另外一个目录中，包含子目录中的内容
 *
 * */
public class CopyAllFileTest {

    public static String oldFileUrl = "/Users/pengxixi/Desktop/java-note/hhd";
    public static String newFileUrl = "/Users/pengxixi/Desktop/java-note/hhd2";

    public static void main(String[] args) {

        // 1.创建一个线程池
        ExecutorService executorService = Executors.newFixedThreadPool(10);

        // 2.向线程中布置任务
        File newFile = new File(newFileUrl);
        if (!newFile.exists()){
            newFile.mkdirs();
        }
        FileEditor fe = new FileEditor(new File(oldFileUrl),newFile);
        executorService.submit(fe);

        // 3.关闭线程池
        executorService.shutdown();
    }
}
